# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=libodfgen
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.1.7
pkgrel=1
pkgdesc="Library to generate ODF documents (mingw-w64)"
arch=('any')
url="https://sourceforge.net/p/libwpd/libodfgen/"
license=("LGPL 2.1")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
depends=("${MINGW_PACKAGE_PREFIX}-librevenge")
options=(staticlibs strip)
source=("https://sourceforge.net/projects/libwpd/files/libodfgen/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.xz"
        enum-without-api-attributes.patch)
sha256sums=('323e491f956c8ca2abb12c998e350670930a32317bf9662b0615dd4b3922b831'
            '3148d825f0d0778cf1b65445919b5fb89ea0c738d6c560893830f08dd5dfebfc')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  #patch -p1 -i ${srcdir}/enum-without-api-attributes.patch
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  cp -r ${srcdir}/${_realname}-${pkgver} "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --with-docs=yes

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.LGPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.LGPL"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING.MPL" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.MPL"
}
